<template>
  <div class="hello">
    <div v-if="isLogin">
      <group>
        <x-button type="primary" plain mini @click.native="toLogin">登录</x-button>
      </group>
    </div>
    <div v-else>
      <span>{{this.$store.state.count}}</span>
      <x-button type="primary" plain mini @click.native="addOne">+1</x-button>
    </div>
  </div>
</template>

<script>
import { GroupTitle, Group, XButton } from 'vux'
export default {
  name: 'Home',
  components: {
    GroupTitle,
    Group,
    XButton
  },
  data () {
    return {
      msg: 'Welcome to Home',
      isLogin: true
    }
  },
  methods: {
    toLogin () {
      console.log(2222)
      this.$router.push('/login')
    },
    addOne () {
      this.$store.commit({
        type: 'increment',
        count: 10
      })
    }
  },
  created: function () {

  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.hello {
  text-align: center;
}
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
